<?php
namespace Admin\Model;
use Think\Model;
class ConfigModel extends Model{
  //读取系统参数生成缓存文件
  public function config_cache(){
      $config=array();
      $res=$this->getField('name,value');
      foreach ($res as  $key=>$val){
        $un_result=unserialize($val); 
        $config[$key]=$un_result?$un_result:$val;
      }
      F('config',$config);
      C($config);//合并参数到全局变量中
      return $config;
  }
  //后台有更新则删除缓存
  protected  function _before_write($data,$option){
      F('config',NULL);
  }
  //后台有删除也删除缓存
  protected function _after_delete($data, $options){
      F('config',NULL);
  }
}